package cn.chenhuanming.shh.administer.entity.jpa;

import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * HouseMessage entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "house_message", catalog = "house")
public class HouseMessage implements java.io.Serializable {

	// Fields

	private Integer id;
	private HouseMessage houseMessage;
	private House house;
	private String message;
	private String messageType;
	private String operationType;
	private LocalDateTime time;
	private String status;
	private Set<HouseMessage> houseMessages = new HashSet<HouseMessage>(0);

	// Constructors

	/** default constructor */
	public HouseMessage() {
	}

	/** minimal constructor */
	public HouseMessage(House house, String message, String messageType,
			String operationType, LocalDateTime time, String status) {
		this.house = house;
		this.message = message;
		this.messageType = messageType;
		this.operationType = operationType;
		this.time = time;
		this.status = status;
	}

	/** full constructor */
	public HouseMessage(HouseMessage houseMessage, House house, String message,
			String messageType, String operationType, LocalDateTime time,
			String status, Set<HouseMessage> houseMessages) {
		this.houseMessage = houseMessage;
		this.house = house;
		this.message = message;
		this.messageType = messageType;
		this.operationType = operationType;
		this.time = time;
		this.status = status;
		this.houseMessages = houseMessages;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_message_id")
	public HouseMessage getHouseMessage() {
		return this.houseMessage;
	}

	public void setHouseMessage(HouseMessage houseMessage) {
		this.houseMessage = houseMessage;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "house_id", nullable = false)
	public House getHouse() {
		return this.house;
	}

	public void setHouse(House house) {
		this.house = house;
	}

	@Column(name = "message", nullable = false)
	public String getMessage() {
		return this.message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	@Column(name = "message_type", nullable = false, length = 3)
	public String getMessageType() {
		return this.messageType;
	}

	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}

	@Column(name = "operation_type", nullable = false, length = 4)
	public String getOperationType() {
		return this.operationType;
	}

	public void setOperationType(String operationType) {
		this.operationType = operationType;
	}

	@Column(name = "time", nullable = false, length = 19)
	public LocalDateTime getTime() {
		return this.time;
	}

	public void setTime(LocalDateTime time) {
		this.time = time;
	}

	@Column(name = "status", nullable = false, length = 3)
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "houseMessage")
	public Set<HouseMessage> getHouseMessages() {
		return this.houseMessages;
	}

	public void setHouseMessages(Set<HouseMessage> houseMessages) {
		this.houseMessages = houseMessages;
	}

}